package com.ys.mapper.storage;

import java.math.BigDecimal;
import java.util.List;

import java.util.Map;
import java.util.Set;


import com.ys.entity.purchase.TcgOfflinePurchaseInStorage;
import com.ys.entity.storage.TccLogisticsComprehensive;
import com.ys.entity.storage.TccLogisticsPlanAlone;
import com.ys.entity.storage.TccTicketBox;
import com.ys.entity.storage.TccTicketBrandName;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface StorageMapper {

	public void deleteBatchTccStockControlDailyByDay(@Param("day")String day);

	public int insertBatchTccStockControlDailyByDay(@Param("day")String day);

	public void deleteBatchTccAllocateDetailByBid(@Param("bidAllocate")String bidAllocate);

	public void deleteBatchTccLogisticsMethodItemSonById(@Param("methodId") Long methodId);

	public void deleteBatchTccLogisticsMethodItemById(@Param("methodId") Long methodId);

	public void deleteBatchTccLogisticsMethodItemTwoById(@Param("methodId") Long methodId);

	public void deleteBatchTccLogisticsChannelMaintItemSonById(@Param("methodId") Long methodId);

	public void deleteBatchTccLogisticsChannelMaintItemById(@Param("methodId") Long methodId);

	public void deleteBatchTccAdditionalBillingMaintTwoById(@Param("methodId") Long methodId);

	public void deleteBatchTccLogisticsCompanyApplyById(@Param("methodId") Long methodId);

	public void deleteBatchTccLogisticsChannelDetailItemSonById(@Param("methodId") Long methodId);

	public void deleteBatchTccLogisticsChannelDetailItemById(@Param("methodId") Long methodId);

	public void deleteBatchTccAdditionalBillingTwoById(@Param("methodId") Long methodId);

	public void deleteBatchTccAdditionalBillingById(@Param("methodId") Long methodId);

	public void deleteBatchTccAdditionalBillingMaintById(@Param("methodId") Long methodId);

	public void updatePreAllocatePublish(@Param("bid")String bid);

	public void deleteBatchTccDistributeDetailByBid(@Param("bidDistribute")String bidDistribute);

	public void deleteBatchTccAllocateCancelDetailByBid(@Param("bidAllocateCancel")String bidAllocateCancel);

	/**
	 * 冻结库存（可用数量减少）
	 */
	public int frozenTccStockControl(@Param("id")Long id, @Param("num")Integer num);

	/**
	 * 解冻库存（可用数量增加）
	 */
	public int thawTccStockControl(@Param("id")Long id, @Param("num")Integer num);

	/**
	 * 扣除库存（可用数量减少、总数量减少）
	 */
	public int reduceTccStockControl(@Param("id")Long id, @Param("num")Integer num);

	/**
	 * 统计未分配数量
	 */
	public int countUnDistributedNumOfTccAllocateDetail(@Param("id")Long id);

	/**
	 * 更新分配状态
	 */
	public int updateStateDistributeOfTccAllocateDetail(@Param("id")Long id);

	/**
	 * 统计精品购买人数
	 * 计算调拨的公司数量
	 */
	public int updateTpBoutiqueNumBuyerAndNumSale(@Param("productCode")String productCode);

	/**
	 * 更新商品组装单子表的剩余数量和实际入库数量
	 */
	public int updateTccAssembleItemOfNum(@Param("id")Long id, @Param("subAssembleLeftNum")Integer subAssembleLeftNum, @Param("subRealStorageNum")Integer subRealStorageNum);

	/**
	 * 计算母件采购价(根据预约采购单)
	 */
	public BigDecimal countPurchaseByPurchaseAppointOrderItem(@Param("itemId")Long itemId);
	
	public Integer getProductNumOfTccStockControl(@Param("id")Long id);
	
	public String getAssembleBidByStockControlId(@Param("stockControlId")Long stockControlId);

	/**
	 * 删除预约调拨发布单 子列表数据，根据bid
	 */
	public int delTccPreAllocatePublishItemByBid(@Param("bid")String bid);

	//删除质检上架货位表信息，根据质检上架单id
	public void deleteTccOnlinePutonLocationByPutonOnlineId(@Param("putonOnlineId")Long putonOnlineId);


	/**
	 * 计算母件采购价(根据采购计划单)
	 */
	public BigDecimal countPurchaseByPurchasePlanSon(@Param("itemId")Long itemId);


	/**
	 * 更新线上商品组装单子表的剩余数量和实际入库数量
	 */
	public int updateTccOfflineAssembleItemOfNum(@Param("id")Long id, @Param("subAssembleLeftNum")Integer subAssembleLeftNum, @Param("subRealStorageNum")Integer subRealStorageNum);

	//删除手工组装单子表信息，根据pbid
	public void deleteTccAssembleByHandByPbid(@Param("pbid")String pbid);

	//删除手工拆装单子表信息，根据pbid
	public void deleteTccDisassembleByHandByHandByPbid(@Param("pbid")String pbid);


	//删除库存调拨单子表信息，根据pbid
	public void deleteTccStockAllocateItemByHandByHandByPbid(@Param("pbid")String pbid);


	/**
	 * 删除采购退货单被调用详情表信息 根据：被调用数据id 、 被调用单据类型（见枚举TccOnlinePurchaseReturnUsedEnum）
	 */
	public int deleteOnlinePurchaseReturnUsedBySource(@Param("usedSourceId")long usedSourceId,@Param("usedSourceType")int usedSourceType);

	//删除货位转移单子表信息，根据pbid
	public void deleteTccLocationTransferItemByPbid(@Param("pbid")String pbid);


	/**
	 * 修改 线上质检上架 状态为删除状态，根据商品组装单号
	 */
	public int updateTccOnlinePutonStateByAssembleBid(@Param("assembleBid")String assembleBid);


	/**
	 * 修改 线上组装报错单 状态为删除状态，根据商品组装id
	 */
	public int updateTccOnlineAssembleErrorStateByAssembleId(@Param("assembleId")Long assembleId);


	/**
	 * 修改线上采购入库
	 * @author Jason
	 */
	int updatTcgOfflinePurchaseInStoragee(TcgOfflinePurchaseInStorage entity);

	/**
	 * 修改FBA装箱单的配货清单号，根据bid
	 */
	public int updateFbaBoxUpDistributionBid(@Param("bidList") List<String> bidList, @Param("distributionBid")String distributionBid);


	/**
	 * 修改FBA装箱单的配货状态，根据bid
	 */
	public int updateFbaBoxUpBoxState(@Param("bidList") List<String> bidList, @Param("boxState")int boxState);

	/**
	 * FBA计划查询库存
	 */
	List<Map<String, Object>> searchStockControlList(@Param("vgsbm") String vgsbm, @Param("shopId") Long shopId, @Param("cck") String cck, @Param("commodityCode") String commodityCode, @Param("commodityName") String commodityName, @Param("page") Integer page, @Param("size") Integer size);

	Integer countStockControlList(@Param("vgsbm") String vgsbm, @Param("shopId") Long shopId, @Param("cck") String cck, @Param("commodityCode") String commodityCode, @Param("commodityName") String commodityName, @Param("page") Integer page, @Param("size") Integer size);

	//删除装箱单箱子信息表 根据bid
	void deleteTccFbaBoxByBid(@Param("bid")String bid);

	//删除装箱单装箱详情信息表 根据bid
	void deleteTccFbaBoxDetailByBid(@Param("bid")String bid);


	//删除运输类型维护，根据类型id
	public void deleteTransportationTypeItemById(@Param("transportationTypeId")Long transportationTypeId);


	/**
	 * 修改FBA装箱单的方案标识，根据计划单号
	 */
	public int updateFbaBoxUpInfoPlacementOptionId(@Param("planBid") String bid, @Param("placementOptionId")String placementOptionId);


	//删除FBA装箱单FBA表信息，根据装箱单号
	public void deleteFbaBoxUpInfoByBid(@Param("bid")String bid);


	//删除FBA装箱单关联表信息，根据装箱单号
	public void deleteFbaBoxRelevanceByBid(@Param("bid")String bid);



	//删除FBA物流方式维护，根据单号和类型
	public void deleteFbaLogisticsMethodBySourceTypeAndSourceBid(@Param("sourceType")Integer sourceType,@Param("sourceBid")String bsourceBidid);

	//删除FBA费用详情，根据单号和类型
	public void deleteFbaFeeDetailsBySourceTypeAndSourceBid(@Param("sourceType")Integer sourceType,@Param("sourceBid")String bsourceBidid);


	/**
	 * 修改FBA装箱单详情表的fbaId数据
	 */
	public int updateFbaBoxDetailFbaId(@Param("fbaBoxUpInfoId") long fbaBoxUpInfoId, @Param("boxId")long boxId, @Param("boxNo")String boxNo);


	/**
	 * 修改FBA装箱单详情表的boxNo数据
	 */
	public int updateFbaBoxDetailBoxNo(@Param("boxId")long boxId, @Param("boxNo")String boxNo);


	/**
	 * 物流订单，按物流订单取消，取消时表单部分字段置空
	 */
	public int updateSetNullByLogisticsComprehensiveWithLogOrderBid(@Param("logOrderBid") String logOrderBid,@Param("status") int status);

	/**
	 * 物流订单，按发票号取消，取消时表单部分字段置空
	 */
	public int updateSetNullByLogisticsComprehensiveWithLogInvoiceNo(@Param("logInvoiceNo") String logInvoiceNo,@Param("status") int status);


	/**
	 * 根据发货id查询物流服务名称
	 * @param fbaDeliverIds
	 * @return
	 */
	public Integer logsticsWayCount(@Param("fbaDeliverIds") String fbaDeliverIds);

	/**
	 * 根据发货id查询物流清关方式
	 * @param fbaDeliverIds
	 * @return
	 */
	public Integer logsticsNameLogsticsClearanceCount(@Param("fbaDeliverIds") String fbaDeliverIds);

	/**
	 * 获取是否重复的数据
	 * @param fbaDeliverIds
	 * @return
	 */
	public List<TccLogisticsPlanAlone> tccLogisticsPlanAloneList(@Param("fbaDeliverIds") String fbaDeliverIds);

	/**
	 * 重新发货标记
	 */
	public int updateCxmark(@Param("id")Long id);



	/**
	 * 删除装箱单、自动按箱时的API返回的预览信息
	 */
	public int delBoxUpAutoAndBoxApiPreviewInfo(@Param("planBid")String planBid,@Param("typeTxt1")String typeTxt1,@Param("typeTxt2")String typeTxt2,@Param("typeTxt3")String typeTxt3,@Param("typeTxt4")String typeTxt4);


	/**
	 * 根据计划单号修改装箱单的方案id
	 */
	public int updateBoxUpPlacementOptionId(@Param("planBid")String planBid,@Param("placementOptionId")String placementOptionId);
	/**
	 * 批量获取物流计划单
	 */
	List<TccLogisticsComprehensive> getLogisticsComByBid(@Param("logInvoiceNos") Set<String> logInvoiceNos);

	/**
	 * 批量修改物流发货id
	 */
	public int updateFbaDeliverById(@Param("fbaDeliverBids") Set<String> fbaDeliverBids);

	/**
	 * 查询拼票的箱子数据
	 * @param fbaDeliverIds
	 * @return
	 */
	public List<TccTicketBox> getTicketBoxList(@Param("fbaDeliverIds") String fbaDeliverIds);

	/**
	 * 获取拼票箱子产品品名
	 * @param fbaDeliverIds
	 * @return
	 */
	public List<TccTicketBrandName> getTccTicketBrandNameList(@Param("fbaDeliverIds") String fbaDeliverIds);



	/**
	 * 删除C88文件管理表信息，根据物流订单号
	 */
	public int delLogisticsSadFileByLogOrderBid(@Param("logOrderBid") String logOrderBid);


	/**
	 * 删除C88文件管理表信息，根据发票号
	 */
	public int delLogisticsSadFileByLogInvoiceNo(@Param("logInvoiceNo") String logInvoiceNo);

	/**
	 * 根据发货id查询fba目的地
	 * @param fbaDeliverIds
	 * @return
	 */
	public List<String> getFbaWarehouseAddrCount(@Param("fbaDeliverIds") String fbaDeliverIds);


	/**
	 * 查询物流渠道费用计算的箱子数据
	 * @param fbaDeliverItemIds
	 */
	public List<TccTicketBox> getTicketBoxListByOrder(@Param("fbaDeliverItemIds") String fbaDeliverItemIds);

	/**
	 * 查询物流渠道费用计算的箱子产品品名
	 * @param fbaDeliverItemIds
	 * @return
	 */
	public List<TccTicketBrandName> getTccTicketBrandNameListByOrder(@Param("fbaDeliverItemIds") String fbaDeliverItemIds);

	/**
	 * 计算FBA的商品采购价*商品数量之和
	 */
	public BigDecimal countPurchaseAmountSum(@Param("id")Long id);



	/**
	 * 删除物流付款单（关税费）子列表，根据单号
	 */
	public int delTccLogisticsPaymentTariffItemByBid(@Param("bid") String bid);



	/**
	 * 删除物流付款单（物流费）子列表，根据单号
	 */
	public int delTccLogisticsPaymentFeeItemByBid(@Param("bid") String bid);




	/**
	 * api取消物流订单后，修改订单状态
	 */
	public int apiCancelStatusByLogisticsComprehensive(@Param("orderNo") String orderNo,@Param("apiPlaceOrderStatus") int apiPlaceOrderStatus);


	/**
	 * 修改API订单号，根据物流发票号
	 */
	public int updateOrderNoByLogisticsComprehensive(@Param("orderNo") String orderNo,@Param("logInvoiceNo") String logInvoiceNo,@Param("apiPlaceOrderStatus") int apiPlaceOrderStatus,@Param("trackingNumber") String trackingNumber);


	/**
	 * api创建订单失败后，修改订单状态
	 */
	public int updateFailStatusByLogisticsComprehensive(@Param("logInvoiceNo") String logInvoiceNo,@Param("apiPlaceOrderStatus") int apiPlaceOrderStatus);



	/**
	 * 修改装箱单的API进度计数
	 */
	public int updateBoxUpApiCount(@Param("planBid") String planBid,@Param("apiCount") int apiCount);



	/**
	 * 修改物流渠道追踪编码，根据发票号
	 */
	public int updateTrackingCodeByLogInvoiceNo(@Param("trackingCode") String trackingCode,@Param("logInvoiceNo") String logInvoiceNo);

	/**
	 * 修改发货单对应追踪编码，根据箱子编号
	 */
	public int updateTransfernoByBoxNo(@Param("transferno") String transferno,@Param("boxNo") String boxNo);




	/**
	 * 删除Fba信息表，根据计划单号
	 */
	public int delBoxUpInfoByPlanBid(@Param("planbid") String planbid);





	/**
	 * 修改装箱单状态，根据计划单号
	 */
	public int updateBoxUpBoxStateByPlanBid(@Param("planbid") String planbid,@Param("boxState") int boxState);



	/**
	 * 删除物流渠道费用详情，根据发票号
	 */
	public int delLogisticsDetailChannelFeeByLogInvoiceNo(@Param("logInvoiceNo") String logInvoiceNo);

	/**
	 * 删除物流渠道详情，根据发票号
	 */
	public int delLogisticsChannelDetailByLogInvoiceNo(@Param("logInvoiceNo") String logInvoiceNo);


	/**
	 * 根据系统订单号获取fba按逗号拼接
	 * @param spOrderBid 系统订单号
	 * @return
	 */
	public String getFbaList(@Param("spOrderBid")String spOrderBid);


	/**
	 * 修改FBA仓库，根据FBA编号
	 */
	public int updateBoxUpFbaWarehouseByFbaNo(@Param("fbaNo") String fbaNo,@Param("bid") String bid,@Param("fbaWarehouse") String fbaWarehouse);


	/**
	 * 修改FBA发货单状态
	 */
	public int updateTccFbaDeliverStateByLogisticsOrder(@Param("status") int status,@Param("bid") String bid);




}